package com.neusoft.elmboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.elmboot.service.PointService;
import com.neusoft.elmboot.util.APIResponse;

@RestController
@RequestMapping("/Point")
public class PointController {
	@Autowired
	private PointService pointService;
	
	@GetMapping("Total")
	public APIResponse getPointByUderId(String userId) {
		return APIResponse.success(pointService.getPointByUserId(userId));
	}
	
	@GetMapping("List")
	public APIResponse getPointsListByUserId(String userId) {
		return APIResponse.success(pointService.getPointsByUserId(userId));
	}
	
	@GetMapping("Created")
	public APIResponse getCreatedPointsListByUserId(String userId) {
		return APIResponse.success(pointService.getCreatedPointsByUserId(userId));
	}
	
	@GetMapping("Consumed")
	public APIResponse getConsumedPointsListByUserId(String userId) {
		return APIResponse.success(pointService.getConsumedPointsByUserId(userId));
	}
	
	@PostMapping("")
	public APIResponse consumePointsByUserId(String userId,int amount) {
		return APIResponse.success(pointService.consumePointByAmount(userId, amount));
	}
}
